package com.android.presenter.info;

import com.android.model.net.HttpObserver;
import com.android.presenter.base.BasePresenter;
import com.android.model.info.UserModel;
import com.android.model.entity.res.SetTradePWDVerifyResult;
import com.android.presenter.iview.ISetTradePWDVerifyView;
import com.android.util.log.LogUtil;

/**
 * author:  TenFace
 * date:    2017/9/27
 * description: 设置交易密码前校验
 */

public class VerifyTradePWDPresenter extends BasePresenter<ISetTradePWDVerifyView> {

    private static final String TAG = VerifyTradePWDPresenter.class.getSimpleName();
    private UserModel mUserModel;

    public VerifyTradePWDPresenter(ISetTradePWDVerifyView iSetTradePWDVerifyView) {
        super(iSetTradePWDVerifyView);
        mUserModel = UserModel.getInstance();
    }

    public void verifySetTradePassword(String token, String password, String emailCode, String phoneCode, String googleCode) {
        mUserModel.verifySetTradePassword(token, password, emailCode, phoneCode, googleCode, new HttpObserver<SetTradePWDVerifyResult>() {
            @Override
            public void onSuccess(SetTradePWDVerifyResult setTradePWDVerifyResult) {
                LogUtil.e(TAG, "校验成功");
                if (mIView != null) {
                    mIView.tradePWDVerifySuccess(setTradePWDVerifyResult);
                }
            }

            @Override
            public void onError(int errType, String errMessage) {
                LogUtil.e(TAG, "失败码：" + errType + "》》信息：" + errMessage);
                if (mIView != null) {
                    mIView.tradePWDVerifyFail(errType, errMessage);
                }
            }
        }, mIView.getLifeSubject());
    }

}
